package com.talos.ums.dal.mysql.warehouseuser;

import com.talos.framework.common.pojo.PageResult;
import com.talos.framework.mybatis.core.mapper.BaseMapperX;
import com.talos.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.talos.ums.controller.admin.warehouseuser.vo.UmsWarehouseUserPageReqVO;
import com.talos.ums.dal.dataobject.warehouseuser.UmsWarehouseUserDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 用户仓库关系表 Mapper
 *
 * @author ${table.author}
 */
@Mapper
public interface UmsWarehouseUserMapper extends BaseMapperX<UmsWarehouseUserDO> {

    default PageResult<UmsWarehouseUserDO> selectPage(UmsWarehouseUserPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UmsWarehouseUserDO>()
                .eqIfPresent(UmsWarehouseUserDO::getUserId, reqVO.getUserId())
                .eqIfPresent(UmsWarehouseUserDO::getWarehouseId, reqVO.getWarehouseId())
                .eqIfPresent(UmsWarehouseUserDO::getWarehouseCode, reqVO.getWarehouseCode())
                .eqIfPresent(UmsWarehouseUserDO::getUserCode, reqVO.getUserCode())
                .eqIfPresent(UmsWarehouseUserDO::getAdminPermission, reqVO.getAdminPermission())
                .eqIfPresent(UmsWarehouseUserDO::getActiveFlag, reqVO.getActiveFlag())
                .betweenIfPresent(UmsWarehouseUserDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(UmsWarehouseUserDO::getCreatorId, reqVO.getCreatorId())
                .eqIfPresent(UmsWarehouseUserDO::getCreatorCode, reqVO.getCreatorCode())
                .likeIfPresent(UmsWarehouseUserDO::getCreatorName, reqVO.getCreatorName())
                .eqIfPresent(UmsWarehouseUserDO::getModifierId, reqVO.getModifierId())
                .betweenIfPresent(UmsWarehouseUserDO::getModifyTime, reqVO.getModifyTime())
                .eqIfPresent(UmsWarehouseUserDO::getModifierCode, reqVO.getModifierCode())
                .likeIfPresent(UmsWarehouseUserDO::getModifierName, reqVO.getModifierName())
                .eqIfPresent(UmsWarehouseUserDO::getTenantId, reqVO.getTenantId())
                .orderByDesc(UmsWarehouseUserDO::getId));
    }

}
